/*
 * Copyright (C) 2016 yixun All Rights Reserved.
 * 
 * LoginLogController.java
 */
package com.yixun.qfbao.controller;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.yixun.common.controller.BaseController;
import com.yixun.common.exception.YIXUNExceptionCode;
import com.yixun.common.exception.YIXUNUNCheckedException;
import com.yixun.common.page.Page;
import com.yixun.common.page.PageUtil;
import com.yixun.qfbao.controller.vo.LoginLogVo;
import com.yixun.qfbao.model.LoginLog;
import com.yixun.qfbao.service.LoginLogService;

/**
 * [文件名称]<br>
 * LoginLogController.java<br>
 * <br>
 * [文件描述]<br>
 * 登陆日志 Controller<br>
 * <br>
 * [修改记录]<br>
 * 2016-03-10 11:01:20 创建 陶俊代码生成器<br>
 * 
 * @author 陶俊代码生成器
 * @version 1.00
 */
@Controller
@RequestMapping("/loginLog")
public class LoginLogController extends BaseController {
	@Autowired
	private LoginLogService mservice;
	private static Logger log = Logger.getLogger(LoginLogController.class);
	
	@RequestMapping({"/manage"})
	public String index(Model model){
		return "/loginLog/manage";
	}
	
	@RequestMapping("/list")
	public @ResponseBody Page<LoginLog> indexJson(LoginLogVo entity,HttpServletResponse response,int page,int rows){
		Page<LoginLog> pageModel = null;
		try {
			pageModel = mservice.getReportPage(entity.toDto(),PageUtil.begin(page,rows),rows);
		}catch (YIXUNUNCheckedException e) {
			log.error("分页信息失败",e);
			pageModel = new Page<LoginLog>();
			pageModel.setErrorMsg(e.getCode()+":"+e.getOutMsg());
		}catch (Exception e) {
			log.error("分页信息失败",e);
			pageModel = new Page<LoginLog>();
			pageModel.setErrorMsg(YIXUNExceptionCode.UNKNOW_EXCEPTON.getDesout());
		}
		return pageModel;
	}
}
